package movee.websocket.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Slf4j
@Controller
@RequestMapping("/websocket")
public class PageController {

    /**
     * 加载前端页面，页面中的js会请求后端建立websocket连接
     * @param cid
     * @return
     */
    @GetMapping("/connection/{cid}")
    public ModelAndView socket(@PathVariable String cid) {
        ModelAndView mav=new ModelAndView("socket");
        mav.addObject("cid", cid);
        return mav;
    }
}
